package com.wh.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wh.dao.PoetryDao;
import com.wh.entity.PageResult;
import com.wh.pojo.Dept;
import com.wh.pojo.Poetry;
import com.wh.service.PoetryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

@Service(interfaceClass = PoetryService.class)
@Transactional
public class PoetryServiceImpl implements PoetryService {

    @Autowired
    private PoetryDao poetryDao;

    @Override
    public PageResult pageQuery(Integer currentPage, Integer pageSize, String queryString) {
        //分页助手
        PageHelper.startPage(currentPage,pageSize);
        Page<Poetry> page = poetryDao.selectByCondition(queryString);
        //构建机返回值
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public void add(Poetry poetry) {
        poetryDao.add(poetry);
    }

    @Override
    public void edit(Poetry poetry) {
        poetryDao.edit(poetry);
    }

    @Override
    public Poetry findById(Integer id) {
        return poetryDao.findById(id);
    }

    @Override
    public void deleteById(Integer id) {
        poetryDao.deleteById(id);
    }
}
